import 'package:flutter/material.dart';
import 'package:flutter_saixiaoli/pages/activity/activeDetail/bottomWidget.dart';
import 'package:flutter_saixiaoli/pages/activity/activeDetail/signUp/signUpFun.dart';
import 'package:flutter_saixiaoli/pages/activity/activeDetail/signUp/travelItem.dart';

class SignUp extends StatefulWidget {
  @override
  State<SignUp> createState() => _SignUpState();
}

class _SignUpState extends State<SignUp> {
  String name = '';
  bool addDis = true;
  int aNum = 0; //成人数量
  int cNum = 0; //儿童数量
  int aPrice = 99; //成人票价
  int cPrice = 90; //儿童票价
  int totalPrice = 0; //总票价
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('选择团期'),
        elevation: 0,
      ),
      body: Column(
        children: [
          Expanded(
              child: SingleChildScrollView(
            child: Container(
              child: Column(
                children: [
                  Container(
                    padding: EdgeInsets.all(12),
                    child: Row(
                      children: [
                        Container(
                          width: 3,
                          height: 17,
                          color: Color.fromRGBO(191, 55, 54, 1),
                        ),
                        Container(
                          child: Text('选择集合地'),
                          margin: EdgeInsets.only(left: 10),
                        )
                      ],
                    ),
                  ),
                  Container(
                    child: BottomWidget(
                      callBack: (name) {
                        this.name = name;
                      },
                    ),
                  ),
                  TravelItem(),
                  Container(
                    padding: EdgeInsets.all(12),
                    child: Column(
                      children: [
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Container(
                              child: Row(
                                children: [
                                  Container(
                                    child: Text(
                                      '成人',
                                      style: TextStyle(
                                          color:
                                              Color.fromRGBO(102, 102, 102, 1)),
                                    ),
                                  ),
                                  Container(
                                    margin: EdgeInsets.only(left: 15),
                                    child: Row(
                                      children: [
                                        Container(
                                          child: Text(
                                            '￥',
                                            style: TextStyle(fontSize: 11),
                                          ),
                                        ),
                                        Container(
                                          child: Text(
                                            '$cPrice',
                                            style: TextStyle(
                                                fontWeight: FontWeight.bold),
                                          ),
                                        )
                                      ],
                                    ),
                                  ),
                                  Container(
                                    child: Text(
                                      '（余位：50）',
                                      style: TextStyle(
                                          fontSize: 11,
                                          color:
                                              Color.fromRGBO(102, 102, 102, 1)),
                                    ),
                                  )
                                ],
                              ),
                            ),
                            Container(
                              child: Row(
                                children: [
                                  InkWell(
                                    onTap: () {
                                      setState(() {
                                        this.aNum = SignUpFun.reduce(aNum);
                                        this.totalPrice =
                                            this.cPrice * this.cNum +
                                                this.aPrice * this.aNum;
                                      });
                                    },
                                    borderRadius: BorderRadius.circular(10),
                                    child: Image.asset(
                                      'images/active/reduce.png',
                                      width: 21,
                                      height: 21,
                                    ),
                                  ),
                                  Container(
                                    margin:
                                        EdgeInsets.symmetric(horizontal: 10),
                                    child: Text('$aNum'),
                                  ),
                                  InkWell(
                                    onTap: () {
                                      setState(() {
                                        //this.aNum +=1;
                                        this.aNum = SignUpFun.add(this.aNum);
                                        this.totalPrice =
                                            this.cPrice * this.cNum +
                                                this.aPrice * this.aNum;
                                      });
                                    },
                                    borderRadius: BorderRadius.circular(10),
                                    child: Container(
                                      child: Image.asset(
                                        'images/active/add_active.png',
                                        width: 21,
                                        height: 21,
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                            )
                          ],
                        ),
                        Divider(
                          height: 30,
                          thickness: 0.5,
                        ),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Container(
                              child: Row(
                                children: [
                                  Container(
                                    child: Text(
                                      '儿童',
                                      style: TextStyle(
                                          color:
                                              Color.fromRGBO(102, 102, 102, 1)),
                                    ),
                                  ),
                                  Container(
                                    margin: EdgeInsets.only(left: 15),
                                    child: Row(
                                      children: [
                                        Container(
                                          child: Text(
                                            '￥',
                                            style: TextStyle(fontSize: 11),
                                          ),
                                        ),
                                        Container(
                                          child: Text(
                                            '$cPrice',
                                            style: TextStyle(
                                                fontWeight: FontWeight.bold),
                                          ),
                                        )
                                      ],
                                    ),
                                  ),
                                  Container(
                                    child: Text(
                                      '（余位：50）',
                                      style: TextStyle(
                                          fontSize: 11,
                                          color:
                                              Color.fromRGBO(102, 102, 102, 1)),
                                    ),
                                  )
                                ],
                              ),
                            ),
                            Container(
                              child: Row(
                                children: [
                                  InkWell(
                                    onTap: () {
                                      setState(() {
                                        this.cNum = SignUpFun.reduce(cNum);
                                        this.totalPrice =
                                            this.cPrice * this.cNum +
                                                this.aPrice * this.aNum;
                                      });
                                    },
                                    borderRadius: BorderRadius.circular(10),
                                    child: Image.asset(
                                      'images/active/reduce.png',
                                      width: 21,
                                      height: 21,
                                    ),
                                  ),
                                  Container(
                                    margin:
                                        EdgeInsets.symmetric(horizontal: 10),
                                    child: Text('$cNum'),
                                  ),
                                  InkWell(
                                    onTap: () {
                                      setState(() {
                                        this.cNum = SignUpFun.add(this.cNum);
                                        this.totalPrice =
                                            this.cPrice * this.cNum +
                                                this.aPrice * this.aNum;
                                      });
                                    },
                                    borderRadius: BorderRadius.circular(10),
                                    child: Container(
                                      child: Image.asset(
                                        'images/active/add_active.png',
                                        width: 21,
                                        height: 21,
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                            )
                          ],
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          )),
          Container(
            decoration: BoxDecoration(boxShadow: [
              BoxShadow(
                  color: Color.fromRGBO(187, 187, 187, 0.4),
                  offset: Offset(0.0, 5.0), //阴影xy轴偏移量
                  blurRadius: 15.0, //阴影模糊程度
                  spreadRadius: 1.0)
            ], color: Colors.white),
            child: Row(
              children: [
                Container(
                  padding: EdgeInsets.only(left: 12),
                  alignment: Alignment.center,
                  width: MediaQuery.of(context).size.width * 0.5,
                  height: 55,
                  color: Colors.white,
                  child: Row(
                    children: [
                      Container(
                        child: Text(
                          '合计：',
                          style: TextStyle(fontSize: 13),
                        ),
                      ),
                      Container(
                        child: Text(
                          '￥',
                          style: TextStyle(
                              fontSize: 11,
                              color: Color.fromRGBO(191, 55, 54, 1)),
                        ),
                      ),
                      Container(
                        child: Text(
                          '$totalPrice',
                          style: TextStyle(
                              color: Color.fromRGBO(191, 55, 54, 1),
                              fontSize: 16),
                        ),
                      )
                    ],
                  ),
                ),
                Material(
                  color: Color.fromRGBO(191, 55, 54, 1),
                  child: InkWell(
                    onTap: () {},
                    child: Container(
                      width: MediaQuery.of(context).size.width * 0.5,
                      height: 55,
                      alignment: Alignment.center,
                      child: Text(
                        '立即报名',
                        style: TextStyle(color: Colors.white, fontSize: 15),
                      ),
                    ),
                  ),
                )
              ],
            ),
          )
        ],
      ),
    );
  }
}
